package com.fatsatsuma.email;

import java.io.Serializable;
import java.text.Format;
import java.text.NumberFormat;
import java.util.Locale;

import org.apache.commons.lang.StringUtils;

/**
 * 
 */
public class VelocityStringUtilities implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5792352303857321108L;

	/**
	 * Default and only constructor
	 */
	public VelocityStringUtilities() {
	}

	/**
	 * Method left pads a string with spaces until it reaches the supplied maximum
	 * size
	 * 
	 * @param input
	 * @param size
	 *          the maximum size
	 * @return the padding size
	 */
	public String leftPad(String input, int size) {
		return StringUtils.leftPad(input, size);
	}

	/**
	 * Formats an amount to a localized currency String
	 * 
	 * @param amount
	 * @return String representation of amount.
	 */
	public String currency(double amount) {
		Format formatter = NumberFormat.getCurrencyInstance(Locale.UK);
		return formatter.format(new Double(amount));
	}

	/**
	 * Pads an integer to the correct size
	 * 
	 * @param input
	 * @param size
	 * @return
	 */
	public String leftPad(int input, int size) {
		return StringUtils.leftPad(Integer.toString(input), size);
	}

	/**
	 * Pads a double to the correct size
	 * 
	 * @param input
	 * @param size
	 * @return
	 */
	public String leftPad(double input, int size) {
		return StringUtils.leftPad(Double.toString(input), size);
	}

	/**
	 * Method right pads a string with spaces until it reaches the supplied
	 * maximum size
	 * 
	 * @param input
	 * @param size
	 *          the maximum size
	 * @return the padding size
	 */
	public String rightPad(String input, int size) {
		return StringUtils.rightPad(input, size);
	}

	/**
	 * Pads an integer to the correct size
	 * 
	 * @param input
	 * @param size
	 * @return
	 */
	public String rightPad(int input, int size) {
		return StringUtils.rightPad(Integer.toString(input), size);
	}

	/**
	 * Pads a double to the correct size
	 * 
	 * @param input
	 * @param size
	 * @return
	 */
	public String rightPad(double input, int size) {
		return StringUtils.rightPad(Double.toString(input), size);
	}
}
